import request from '@/utils/request.js';

// 新建执行策略
export function createStrategy(data){
  return request({
    url: '/algoExecStrategy/createAlgoExecStrategy',
    method: 'post',
    data
  })
}

// 更新执行策略
export function updateStrategy(data){
  return request({
    url: '/algoExecStrategy/updateAlgoExecStrategyInfo',
    method: 'post',
    data
  })
}

// 删除执行策略
export function delStrategy(params){
  return request({
    url: '/algoExecStrategy/deleteAlgoExecStrategy',
    method: 'post',
    params
  })
}

// 根据id获取执行策略详情
export function getStrategyDetail(params){
  return request({
    url: '/algoExecStrategy/getAlgoExecStrategyInfoById',
    method: 'post',
    params
  })
}

// 分页获取策略列表
export function getStrategyList(data){
  return request({
    url: '/algoExecStrategy/getAlgoExecStrategyPageList',
    method: 'post',
    data
  })
}

// id生成器
export function createId(){
  return request({
    url: '/algoExecStrategy/getAlgoExecStrategyId',
    method: 'post'
  })
}

// 切换策略状态
export function changeStrategyStatues(params){
  return request({
    url: '/algoExecStrategy/swatchAlgoExecStrategyStatus',
    method: 'post',
    params
  })
}

// 创建组合算法拉取策略的下一步步骤
/**
 * 
 * @param {
 *  strategyId,
 *  nowEventId,
 *  algoExecStrategyEvents: [
 *    { id, optName, optSort }
 *  ]   
 * } data 
 * @returns {
 *  id, name, description, type, algoExecStratgyOpts: [
 *    { id, optName, optSort }
 *  ]
 * }
 */
export function getStep(data){
  return request({
    url: '/algoExecStrategySequenceFlow/getNextAlgoExecStrategyEventByAlgoExecStrategyEvents',
    method: 'post',
    data
  })
}